package com.zlm.app.partner.controller;

import com.zlm.app.partner.service.UserEmpService;
import com.zlm.app.partner.service.UserPartnerService;
import com.zlm.common.constants.CodeConstants;
import com.zlm.common.dto.JsonResultDto;
import com.zlm.common.dto.userEmp.OrgParamsDto;
import com.zlm.common.dto.userEmp.PositionParamsDto;
import com.zlm.common.enums.JobHuntingStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 合伙人版首页
 * @Author: duyufu
 * @Date: 2019/7/23 16:11
 */
@RestController
@RequestMapping(value = "/partHomePage")
public class PartHomePageController extends CheckController{

    @Autowired
    private UserPartnerService userPartnerService;

    @Autowired
    private UserEmpService userEmpService;

    /**
     * 获取轮播图
     * @param type
     * @return
     */
    @GetMapping("/getSysBannerByType")
    public JsonResultDto getSysBannerByType(Integer type) {
        try {
            JsonResultDto result = userEmpService.getSysBannerByType(type);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 获取职位列表
     * @param positionParamsDto
     * @return
     */
    @PostMapping("/getPositionList")
    public JsonResultDto getPositionList(PositionParamsDto positionParamsDto) {
        try {
            JsonResultDto result = userEmpService.getPositionList(positionParamsDto);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 分页获取明星企业
     * @param orgParamsDto
     * @return
     */
    @PostMapping("/queryStarEnterprise")
    public JsonResultDto queryStarEnterprise(OrgParamsDto orgParamsDto) {
        try {
            JsonResultDto result = userEmpService.queryStarEnterprise(orgParamsDto);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 分页获取附近人才
     * @param pageNumber
     * @param pageSize
     * @param lng
     * @param lat
     * @return
     */
    @GetMapping("/queryLocalEmp")
    public JsonResultDto queryLocalEmp(Integer pageNumber, Integer pageSize, Double lng, Double lat) {
        try {
            JsonResultDto result = userEmpService.queryLocalEmp(pageNumber,pageSize,lng,lat);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 获取人才教育经历
     * @param token
     * @param empId
     * @return
     */
    @GetMapping("/queryUserEducation")
    public JsonResultDto queryUserEducation(String token,Integer empId) {
        try {
            if (null == empId) {
                throw new RuntimeException(CodeConstants.CODE_PARAMS);
            }
            checkToken(token);
            JsonResultDto result = userEmpService.queryUserEducation(empId);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (Exception e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

    /**
     * 获取人才工作经历
     * @param token
     * @param empId
     * @return
     */
    @GetMapping("/queryUserExperience")
    public JsonResultDto queryUserExperience(String token,Integer empId) {
        try {
            if (null == empId) {
                throw new RuntimeException(CodeConstants.CODE_PARAMS);
            }
            checkToken(token);
            JsonResultDto result = userEmpService.queryUserExperience(empId);
            checkJsonResultDto(result);
            return success(result.getData());
        } catch (RuntimeException e) {
            e.printStackTrace();
            return fail(e.getMessage());
        }
    }

//    public JsonResultDto query
}
